package servlets;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet("/loginServlet")
public class loginServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    	
    	
    	response.setContentType("text/html");
		PrintWriter out = response.getWriter();
		
		
		String login = request.getParameter("username");
		String senha = request.getParameter("userpass");
		
		if ((login.equals("fernando") || login.equals("rodrigo") || login.equals("arduino")) && senha.equals("arduino")){
			request.getSession().setAttribute("username", login);
			request.getSession().setAttribute("dia", null);
			response.sendRedirect("index.jsp");
		}else{
			out.print("SENHA INVALIDA");
			response.sendRedirect("login.jsp");
			
		}
		
	}

}
